package com.ptu.controller.user;

import com.ptu.dto.StorePageQueryDTO;
import com.ptu.result.PageResult;
import com.ptu.result.Result;
import com.ptu.service.StoreService;
import com.ptu.vo.StoreVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 员工管理
 */
@RestController("userStoreController")
@RequestMapping("/user/store")
@Slf4j
@Api(tags = "店家相关接口")
public class StoreController {

    @Autowired
    private StoreService storeService;


    /**
     * 分页查询
     * @param storePageQueryDTO
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("店铺分页查询")
    public Result<PageResult> page(StorePageQueryDTO storePageQueryDTO){
        log.info("店铺分页查询，参数为：{}",storePageQueryDTO);
        PageResult pageResult = storeService.pageQuery(storePageQueryDTO);
        return Result.success(pageResult);
    }


    @GetMapping("/{id}")
    @ApiOperation("根据id查询店铺")
    public Result<StoreVO> getById(@PathVariable Long id){
        StoreVO storeVO = storeService.getById(id);
        return Result.success(storeVO);
    }

}
